<%--
    Document   : graficasaldos
    Created on : 13/10/2011, 10:14:01 PM
    Author     : Victor
--%>

<%@page import="java.sql.ResultSet"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<%@ page  import="java.awt.*" %>
<%@ page  import="java.io.*" %>
<%@ page  import="org.jfree.chart.*" %>
<%@ page  import="org.jfree.chart.axis.*" %>
<%@ page  import="org.jfree.chart.entity.*" %>
<%@ page  import="org.jfree.chart.labels.*" %>
<%@ page  import="org.jfree.chart.plot.*" %>
<%@ page  import="org.jfree.chart.renderer.category.*" %>
<%@ page  import="org.jfree.chart.urls.*" %>
<%@ page  import="org.jfree.data.category.*" %>
<%@ page  import="org.jfree.data.general.*" %>
<%@ page  import="Monetario.ConexionMysql" %>

<%
  final double[][] data = new double[][]{
  {210, 300, 320, 265, 299},
  {200, 304, 201, 201, 340}
  };

 final CategoryDataset dataset =
  DatasetUtilities.createCategoryDataset(

  "Team ", "", data);

   DefaultPieDataset myColoredPieChart = new DefaultPieDataset();
                /* Define Values for the Pie Chart - Programming Languages Percentage Difficulty */
    ConexionMysql conexion=new ConexionMysql();
    ResultSet rs=conexion.GenerarR("Select * From agencia");
                while (rs.next())

{
    myColoredPieChart.setValue(rs.getString (2),rs.getInt (4));
}


 

  DefaultCategoryDataset dataSet = new DefaultCategoryDataset();

ConexionMysql conexion2=new ConexionMysql();
    ResultSet rs2=conexion2.GenerarR("Select * From agencia where id_agencia=1");
                while (rs2.next())

{
    dataSet.setValue(rs2.getInt (4), "Saldo", "Disponible");
    dataSet.setValue(rs2.getInt (5), "Saldo", "Reservado");
    dataSet.setValue(rs2.getInt (4)+rs2.getInt(5), "Saldo", "Real");
}



  JFreeChart chart = ChartFactory.createBarChart("Saldos de la agencia", "Saldo", "Tipo de Saldo",dataSet, PlotOrientation.VERTICAL, true, true, true);



 try {
  final ChartRenderingInfo info = new ChartRenderingInfo
   (new StandardEntityCollection());

 final File file1 = new File("E:\\Yojugracu\\Documents\\Yonatan\\Semestre8\\Base de Datos 2\\SVN_BASES_prueba23-10\\BASES2_SEMESTRE2\\build\\web\\areachart.png");

 ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
  } catch (Exception e) {
  out.println(e);
  }


%>

<html>
  <head>
  <meta http-equiv="Content-Type"
   content="text/html; charset=UTF-8">
  <title>JSP Page</title>
  </head>
  <body>

  </body><IMG SRC="areachart.png" WIDTH="600" HEIGHT="400" BORDER="0">
</html>